<template >
	<view style="width: 100%; height: 765px;  background-color:#f4f4f4;">
		  <u-radio-group
		    v-model="radiovalue1"
            @change="radiochange"
		    placement="column">
			<view v-for="a in sitelist" style="width: 95%; height: 130px; margin: 0 auto; border-radius:15px; margin-top: 10px; background-color: #fff;">
				<u-row>
					<u-col span=1.5><div style="width: 40px; height: 30px; background-color:#1890FF; color: #fff; text-align: center; line-height:2 ;">{{a.regionType == 0?'家': a.regionType == 2?'学校': (a.regionType == 1 ? '公司' : '')}}</div></div></u-col>
					<u-col span=10.5><view style="heigh: 80px; width: 100%;">
								<p style="font-size: 18px; font-weight: 900; margin-top: 5px;">{{a.detailedAddress}}</p>
								<u-row>
								<u-col span=5><p style="margin-top: 10px; color: #c8c9cc">{{a.consigneeName}}</p></u-col>
								<u-col sp   an=5><p style="margin-top: 10px; color: #c8c9cc">{{a.clientPhone}}</p></u-col>
								</u-row>
					</view></u-col>
				</u-row>
				<u-line></u-line>
				<u-row style="margin-top: 10px; margin-left: 20px; ">
					<u-col span=6> 
					<u-radio
				  :customStyle="{marginBottom: '8px'}"
				  :name="a.id"
				  label="默认"
					></u-radio>
					</u-col span=8> 	
					<u-col span=4><view ><u-icon name="close-circle-fill" size="18px" style="float: left; margin-top: 2px;"></u-icon>删除</view></u-col>
					<u-col><view ><u-icon name="edit-pen-fill" size="18px" style="float: left; margin-top: 4px; margin-left: -15px;"></u-icon>编辑</view></u-col>
				</u-row>
			</view>
			
		</u-radio-group>
		<view>	<u-button  @click="addadderess()" style="width: 100px; height: 40px; margin-top: 21px;" type="primary" text="新增地址"></u-button></view>
	</view>
	
</template>
<script>
	export default {
		data() {
			return {
				radiovalue1:1,
				sitelist:[{
					id: 0, 
					consigneeName:'',//收货人姓名
					clientAddress:'', //地址
					clientPhone:'', //联系电话
					clientEconomize:'', //省、
					clientCity:'', //市
					clientCounty:'', //县
					detailedAddress:'',//详细地址
					regionType:'' //地区类型
				}],
			}
		},
		mounted () {
            var userId = uni.getStorageSync("loginId")
            if(userId){
                this.userId = userId
            } 
            var that = this
		  this.listsilet() //地址单查
          uni.request({
              url:'http://'+that.$host+':'+that.$port+'/address/getDefaultAddByUserId?userId='+that.userId,
              success(res) {
                  console.log(res.data)
                  that.radiovalue1 = res.data.obj.id
                  // console.log("123123123:"+that.radiovalue1)
              }
          })
		},
		methods: {
                
            radiochange(a){
                var that = this
                console.log(a)
                console.log("value::"+this.radiovalue1)
                uni.request({
                    url:"http://"+that.$host+":"+that.$port+"/address/updateUserDefaultAddr?userId="+that.userId+"&AddrId="+a,
                    success(res){
                        
                    }
                })
            },
			listsilet(){
                var that = this
				uni.request({
						url: "http://"+that.$host+":"+that.$port+"/address/addressList?userId="+that.userId ,               
						method: 'GET',
						dataType: 'json',
						// data:{userId : that.id},
						success: (res) => {
						this.sitelist = res.data.obj
							},                  	
						});
			},
			addadderess(){
				uni.navigateTo({
					url:'/pages/mine/addaddress/addaddress'
				})
			}
		}
	}
</script>

<style>

</style>
